//函数的声明
function add(a:number, b:number):number{
  return a + b;
}

//箭头函数
let sub = (a: number, b: number):number => {
  return a - b;
}

// sub(123, 0x123);
//函数另一种声明
let times: (a: number, b: number) => number;
times = function(a, b){
  return a * b;
}

//合在一起的写法
let divide: (a: number, b: number) => number = (a, b) => {
  return a / b;
};

//函数省略返回值类型声明
let yu = (a: number, b: number) => {
  return a % b;
}

//可选参数  作用: 截取字符串  splice  slice  addEventListener
// let slice = (str: string, start: number, end ?: number) => {

// }
// slice('love', 1, 2);
// slice('love', 1);

//参数默认值
// let buildPhone = (code:string, area:string='+86') => {

// }
// buildPhone('18319840924', '+86');
// buildPhone('18319840924');

// rest 参数  push  splice
let sum = (...args: number[]) => {
  console.log(args);
  
}

sum(1);
sum(1,2);
sum(1,2,3);
sum(1,2,3,5);


